<template>
	<view>
		<scroll-view class="scroll-box" scroll-y @scrolltolower="scrollpage">
			<card v-for="(item,index) in List" Tasktype="" :key="index" :data="item" :index="index"  @Tap="maskDetail" @message="messageTypeOpen(item.id)"></card>
			<Message :Taskid="taskid" v-if="messageType == true" @close="messageTypeClose"></Message>
		</scroll-view>
	</view>
</template>

<script>
	import Message from '@/pages/mask/component/disalog/message/message.vue'
	import * as api from '@/utils/api.js';
	import card from '@/pages/mask/component/card/card.vue';
	export default {
		components:{
			card,Message
		},
		data() {
			return {
				apiinfo:{
					leaderId:null,
					pageSize:15,
					currentPage:1,
					projectId:null,
					status:null,
				},
				isscrollPage:true, // 是否允许翻页
				messageType:false, // 消息弹窗显示状态
				taskid:null, // 任务id
				List:[], // 任务列表
			}
		},
		onLoad(option) {
			let apiinfo = this.apiinfo;
			if(option.leaderid){
				apiinfo.leaderId = option.leaderid;
			}
			if(option.projectid){
				apiinfo.projectId = option.projectid;
			}
			if(option.status){
				apiinfo.status = option.status;
			}
			this.apiinfo = apiinfo;
			this.projectMemberDetail();
		},
		methods: {
			scrollpage:function(){
				let apiinfo =this.apiinfo;
				let isscrollPage = this.isscrollPage;
				if(isscrollPage){
					apiinfo.currentPage += 1;
					this.apiinfo = apiinfo;
					this.projectMemberDetail();
				}
			},
			/**
			 * 详情接口
			 */
			projectMemberDetail:function(){
				let List = this.List;
				api.memberDetailByStatus(this.apiinfo).then(res=>{
					if(res.data.result.list.length== 0){
						this.isscrollPage = false;
						uni.showToast({
							title: '没有更多',
							icon:'none',
							duration: 2000
						});
					}
					List.push.apply(List,res.data.result.list);
					this.List = List;
				})
			},
			/**
			 * 消息弹窗开启触发事件
			 */
			messageTypeOpen:function(id){
				this.taskid = id;
				this.messageType = true;
			},
			/**
			 * 消息弹窗关闭触发事件
			 */
			messageTypeClose:function(){
				this.messageType = false;
			},
			/**
			 * 跳转至任务详情页面
			 */
			maskDetail:function(data){
				console.log(data);
				uni.navigateTo({
					url: '/pages/mask/detail/detail?id=' + data.id,
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.scroll-box{
		width: 100%;
		height: 100vh;
	}
</style>
